home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / vtkermit.arc / SCRIPT.DOC < prev    next >
Encoding:
INI File  |  1986-02-13  |  24.9 KB  |  606 lines

  1. [SCRIPT.DOC] -- Documentation for VTKermit's Script Facility -- 2 Feb 86
  2.  
  3. VTKermit's Script Facility is a small special-purpose programming language
  4. which is tied into the VTKermit VT100 terminal emulator.  It enables a
  5. programmer to create a program which can control a communications session and
  6. act as an interface between the user and a remote host, as well as controlling
  7. any modem, network or other mechanism required to access a remote host.  The
  8. most typical use of a script is to log a user into a remote computer over a
  9. dialup line, but many other uses are possible.
  10.  
  11. Beyond the most typical uses of scripts are some useful features that can be
  12. provide greater customization possibilities.  Scripts can ask a user
  13. questions, store the answers in variables, test those variables in simple
  14. ways, set other variables, take different actions depending on user or host
  15. input, send text to the host, wait for responses from the host or timeout
  16. waiting for one, sleep for brief periods, loop within a script, call and chain
  17. from script to script and create and write to disk files.  This is far short
  18. of a general purpose programming language like FORTRAN or C, but is powerful
  19. nonetheless.
  20.  
  21. There are two types of VTKermit scripts:  script-files, which are standard
  22. ASCII text files with lines delimited by CR-LF, and script-macros, which are
  23. macros interpreted as scripts.  Script-files are created with any ASCII text
  24. editor, while script-macros are created with the VTKermit DEFINE command.
  25. Script-files are executed with the SCRIPT-FILE command, and script-macros are
  26. executed with the DO-SCRIPT command.  As with all macros, the maximum size of
  27. a script-macro is 255 characters.  This means that any non-trivial script will
  28. have to be implemented as a separate ASCII file.
  29.  
  30. Once a script has been created and the invoking SCRIPT-FILE command given, the
  31. Script Processor takes over control of your keyboard and you are thrown into
  32. Terminal Emulation mode.  You will see the entire communications session take
  33. place on your screen, but any keyboard input you provide will be ignored
  34. unless the script is specifically prompting you for something.  If you see
  35. that the script is not working for some reason, you can always type CONTROL-C
  36. to abort the script.  You will be left in Terminal mode at the point that you
  37. typed CONTROL-C -- you can then take whatever action is required to continue
  38. or terminate the communications session, and press F5 (or ALT-F5) to leave
  39. Terminal mode.  It sometimes takes a lot of tries to build a bulletproof
  40. script which will handle all typical circumstances properly (e.g. modem
  41. unplugged, phone unplugged, host not available, etc.), so CONTROL-C can be
  42. very helpful during script debugging.
  43.  
  44. A script consists of script commands, labels, comments, line separators and
  45. whitespace.  Every script command begins with a script verb, and most script
  46. commands take one or more arguments.  Script verbs may be in upper, lower or
  47. mixed case.
  48.  
  49. Script arguments are usually surrounded by delimiters, which can be almost any
  50. printable ASCII character you want.  This makes it easy to include most ASCII
  51. characters in the script argument, since any character not used in the
  52. argument may act as the delimiter.  Also, control characters may be invoked
  53. within delimited text by using up-arrow (carat) constructs, such as ^M for CR,
  54. ^J for LF or ^[ for ESCape.  The sequence "^^", however, is converted to "^"
  55. to allow the up-arrow character to be included.  To get the ASCII character
  56. control-uparrow you should type uparrow-tilde ("^~").  The control character
  57. conversion function ignores the case of its argument, so ^M and ^m will both
  58. invoke CR.
  59.  
  60. Script labels, which are tags to be used in jumping around the script, are not
  61. enclosed in delimiters, since labels are not supposed to contain
  62. nonalphanumeric characters.
  63.  
  64. Two printable characters are reserved within a script and may not be used as
  65. delimiters:  exclamation point and semicolon.  Exclamation is used as a
  66. comment-begin character, and semicolon is used as a line separator.  Either of
  67. these characters may be used within a delimited argument.
  68.  
  69. A script is primarily line-oriented:  most script commands end at the end of
  70. the line they begin on.  However, if a script verb takes a delimited argument,
  71. that argument may span multiple lines.  Internally, CR-LF pairs in a delimited
  72. argument are treated as CR -- usually the right thing to do when sending text
  73. which spans multiple lines.
  74.  
  75. The semicolon provides a mechanism for putting multiple script commands on the
  76. same line.  At any point that a script command might be considered logically
  77. complete, you may insert a semicolon and continue with another script command
  78. on the same line.
  79.  
  80. Similarly, an exclamation point inserted at a logical command end will cause
  81. the rest of the line to be treated as a comment.  A semicolon within a comment
  82. does not terminate the comment -- comments are terminated only with CR.
  83.  
  84. Scripts provide support for simple variables.  Script variables always hold
  85. ASCII text which must not exceed 94 characters in length, and always have
  86. names which begin with a percent-sign.  Each variable name can be as long as
  87. 31 characters (including the percent) and can contain dashes or underscores to
  88. inprove readability.  There may be as many as 20 variables defined.  After
  89. that limit, additional variables will not be created.
  90.  
  91. Variables are set with any of the ASK, NASK or LET commands, and may be
  92. invoked in any delimited string simply by naming them and terminating them
  93. with a space which is treated as part of the variable name (i.e. ignored).
  94. Invoking an undefined variable will give a single percent-sign, so percent-
  95. signs may be easily included in delimited text by typing percent-percent-space
  96. (for example) where a percent is desired.
  97.  
  98. Variables remain intact as long as script processing continues, so CALLed and
  99. CHAINed script may use the variables of the calling/chaining script, or may
  100. set new variables for use by the calling script.  Leaving the script processor
  101. and returning later, however, will erase all variable definitions.
  102.  
  103. Scripts can sleep (sit and do nothing) for periods of seconds or hundredths of
  104. seconds.  The maximum quantity should be 150 or less -- either 2.5 minutes
  105. (150 seconds) or 1.5 seconds (150 hundredths of a second).  Similarly, a timer
  106. can be set to abort a "wait" in which the script is waiting for host output.
  107. The timer can be up to 150 seconds or 150 hundredths of a second.  Due to the
  108. way sleeps and timer are implemented, only one can be in effect at a time
  109. (that is, a SLEEP command will clobber any TIMER which is set).
  110.  
  111. Verbs may be abbreviated to the shortest abbreviation which is still unique.
  112. To allow for the possibility of future versions of VTKermit which may have
  113. additional verbs, you should not overdo this.
  114.  
  115. All verbs, variables and labels may be entered in upper, lower or mixed case.
  116. Internally, these are all treated as upper case.  Delimited text, on the other
  117. hand, it not case-converted at all -- mixed case text is sent as mixed case.
  118.  
  119. Whitespace (combinations of space and tab) are generally ignored between
  120. script verbs and arguments or between script commands.  Appropriate use of
  121. whitespace can improve script readability.  Blank lines are ignored, so these
  122. may also be used to improve readability.
  123.  
  124. Scripts generally are composed of sequences of standard activities.  Text can
  125. be sent to the host (out the serial port) with SEND or displayed on the screen
  126. with PRINT.  The script can SLEEP for a period of time, or can block WAITing
  127. for some particular host output, optionally abortable when a TIMER expires.
  128. To avoid "race conditions" in which host output is returned before the script
  129. can WAIT for it, you can enable buffering of host output with a LISTEN
  130. command.  You can jump from one script to another with CHAIN, or jump-and-
  131. return with CALL.  Disk files may be created (or zeroed) with an OPEN command,
  132. written to with WRITE then closed with CLOSE.  Finally, you can terminate the
  133. script by leaving to COMMAND-MODE or TERMINAL-MODE or quit the program
  134. entirely with EXIT-TO-DOS.  Hitting end-of-file on the outermost (unCALLed)
  135. script will leave you in Terminal mode.
  136.  
  137. There are currently 27 script commands, some of which are trivial variations
  138. on each other.  All the commands are described here.  Each command is
  139. described first in a general way, followed by the exact command format.  For
  140. some commands, this will be followed by a discussion of any special details
  141. you may need to know to use the command, and an example of a typical use.
  142.  
  143. In the descriptions below, the following definitions apply:
  144.  
  145.   [optional]        An item in square braces is optional
  146.   %variable         A variable name, including the percent-sign, always
  147.                       terminated with a space, which is "eaten" (not used)
  148.   delimited-text    A delimiter, any amount of text, the delimiter again
  149.   label             A label to be jumped to
  150.   number            A number between 0 and 150
  151.   condition         A condition code set by WAIT, or a comparison
  152.                       between a variable and a delimited string
  153.   command           Another VTKermit command, usually a GOTO or BACKTO
  154.   =                 A literal equal-sign (=)
  155.   NO-OP             No-operation ... do nothing
  156.  
  157.  
  158. ASK
  159.     ASK is used to get a value for a variable from the user.  ASK
  160.     will prompt the user by typing a text string to the screen (using
  161.     the VT100 channel, so ESC sequences may be used) and will wait
  162.     for text to be typed followed by Enter (CR).  Any typed text will
  163.     be echoed to the screen.
  164.  
  165.                ASK    variable    delimited-text
  166.  
  167.     ASK is often used prior to beginning a communications session so
  168.     that required parameters will be established up-front.
  169.  
  170.              ASK %userid "What is your User-ID: "
  171.  
  172.  
  173. BACKTO
  174.     BACKTO performs backward branching within a script file.
  175.  
  176.                 BACKTO    label
  177.  
  178.     BACKTO sets a pointer to the start of the file and then searches
  179.     forwards just like a GOTO.  Labels should be unique for best results.
  180.  
  181.                  BACKTO Start
  182.  
  183.  
  184. CALL
  185.     CALL sets a pointer in the current script and thens runs another
  186.     script-file, optionally starting execution at a specified label.
  187.  
  188.             CALL    delimited-text    [label]
  189.  
  190.     The delimited-text is a full DOS 2.0 file specification which may
  191.     contain a path name.  The label is optional and, if used, will
  192.     cause an implicit GOTO to the label once the script is started.
  193.     If the specified script file is not found, this instruction is a
  194.     NO-OP.
  195.  
  196.              CALL "c:\scripts\error.scr" No_modem
  197.  
  198.  
  199. CHAIN
  200.     CHAIN leaves the current script and then runs another script,
  201.     without returning, optionally starting execution at a label.
  202.  
  203.                CHAIN    delimited-text    [label]
  204.  
  205.     The delimited-text is a full file spec, as with CALL.  The label
  206.     is optional.  If the specified script file is not found, this
  207.     instruction is equivalent to a GOTO to the end of the current
  208.     script.
  209.  
  210.                    CHAIN "part2.scr"
  211.  
  212.  
  213. CLOSE
  214.     CLOSE closes any file which was openned with the OPEN command.
  215.  
  216.                      CLOSE
  217.  
  218.     If no file is open, this is a NO-OP.
  219.  
  220.  
  221. COMMAND-MODE
  222.     The COMMAND-MODE command immediately terminates script processing
  223.     and exits back to Command mode (or Menu mode if SET MODE MENU has
  224.     been given).  It will terminate any number of CALLs.
  225.  
  226.                  COMMAND-MODE
  227.  
  228.  
  229. CR
  230.     A synonym for SENDCR.  See below.
  231.  
  232.  
  233. EXIT-TO-DOS
  234.     The EXIT-TO-DOS command immediately terminates script processing
  235.     and exits completely back to DOS.  It will terminate any number of
  236.     CALLs.
  237.  
  238.                   EXIT-TO-DOS
  239.  
  240.  
  241. GOTO
  242.     The GOTO command performs a forward jump through the current script
  243.     file searching for a specific label.  (Labels are always the first
  244.     text on a line and end with a colon.)
  245.  
  246.                  GOTO    label
  247.  
  248.     If the specified label is not found, end-of-file will be hit and the
  249.     current script will terminate.  If the current script was CALLed,
  250.     execution will then continue in the calling script.
  251.  
  252.                  GOTO We_are_connected
  253.  
  254.  
  255. HSLEEP
  256.     HSLEEP sleeps (does nothing) for a period of hundredths of seconds.
  257.  
  258.                    HSLEEP    number
  259.  
  260.     HSLEEP is useful for short delays of less than a second.  Some
  261.     modems, and probably some remote hosts, do not respond to text which
  262.     is sent too quickly, but a delay of a full second may be more than
  263.     is needed.  HSLEEP allows for "micro-sleeps" of a fraction of a
  264.     second.
  265.  
  266.               HSLEEP 50   ! Sleep for 1/2 second
  267.  
  268.  
  269. HTIMER
  270.     HTIMER sets a very short timer to abort a WAIT.
  271.  
  272.                    HTIMER    number
  273.  
  274.     HTIMER might be useful when waiting for an event that will
  275.     happen either very quickly or not at all, such as a response
  276.     from a connected modem.
  277.  
  278.                   HTIMER 150
  279.  
  280.  
  281. IF
  282.     The IF command has two forms, one of which is used to test a
  283.     completion code of a WAIT, the other of which is used to compare
  284.     a variable with a delimited string.
  285.  
  286.               IF    condition    command
  287.  
  288.     The first form is used following a WAIT command to determine what
  289.     event terminated the WAIT.  In this case, the "condition" will be
  290.     a number between 1 and the number of waiting items (see WAIT for
  291.     further discussion) or 255.  Lower numbers indicate the matching
  292.     waiting item, while 255 means "timeout".  255 will only occur if
  293.     a TIMER had been set prior to entering the WAIT.
  294.  
  295.     The second form is used to test a variable to see if it begins
  296.     with a certain string of characters.  The format of the condition
  297.     in this case is
  298.  
  299.                %variable    =    delimited-text
  300.  
  301.     Only "equality" can be tested for, and this test is actually for
  302.     "abbreviation".  Thus, "%system = /A/" will be true if %system is
  303.     "A" or "ABCDEF", but false if %system is "B".
  304.  
  305.     When the tested condition is true, the command which follows will
  306.     be executed:  when false, the command will be skipped.  The most
  307.     useful command is usually GOTO or BACKTO, since these allow more
  308.     than one command to be executed in response to the condition.
  309.  
  310.                   IF 1 GOTO We_are_in
  311.                       or
  312.               IF %modem = "H" GOTO HAYES
  313.  
  314.  
  315. LET
  316.     The LET command sets a variable to a specified value.
  317.  
  318.             LET    %variable    =    delimited-text
  319.  
  320.     This is often useful when several items should be set in unison.
  321.     You might query the user for some selector (e.g. "Which system?")
  322.     and then set several variables based on the user's response.
  323.     Another use is when there might be several paths through front-end
  324.     scripts leading to a final "worker" script in which some front-ends
  325.     prompt the user for values (with ASK) and others just force those
  326.     values with LET.
  327.  
  328.             LET %Phone_number = "555-1212"
  329.  
  330.  
  331. LISTEN
  332.     Ordinarily, the script processor pays no attention to what is
  333.     received from the remote host.  When a WAIT command is executed,
  334.     however, script processing halts until either some specified text
  335.     is received from the host or a timeout occurs.  Often the received
  336.     text will be triggered in the host by something sent by the script.
  337.     In this case, there may be circumstances in which the hosts response
  338.     will come so fast that the WAIT command hasn't even been set up yet,
  339.     in which case the WAIT will not see the host's text.  The LISTEN
  340.     command can be used to turn on "listening" to host output BEFORE
  341.     the triggering text is sent, assuring that the host's response will
  342.     be seen.  Ordinarily, "listening" begins when the WAIT command is
  343.     executed.
  344.  
  345.                     LISTEN
  346.  
  347.  
  348. LWAIT
  349.     LWAIT is a variant of the WAIT command that does not turn off
  350.     listening when it finishes.  It prevents the script processor from
  351.     being "deaf" to host output, which would ordinarily happen between
  352.     WAIT commands.  It can be used to wait in succession for several
  353.     host responses which may come all in a row.  The format is
  354.     identical to that of the WAIT command, which you should also see.
  355.  
  356.         LWAIT    delimited-text    [delimited-text ...]
  357.  
  358.  
  359. NASK
  360.     NASK is a variant of ASK which does not echo user-typed text to
  361.     the screen.  This is most useful when prompting for passwords.
  362.  
  363.               NASK    %variable    delimited-text
  364.  
  365.  
  366. OPEN
  367.     The OPEN command either creates or erases-and-opens the specified
  368.     file.  This must be performed prior to using the WRITE command.
  369.  
  370.                 OPEN    delimited-text
  371.  
  372.     The delimited-text is a DOS 2.0 file specification.  If the file
  373.     cannot be created or opened, this command is a NO-OP.
  374.  
  375.  
  376. PRINT
  377.     PRINT sends its argument to the screen through the VT100 filter.
  378.     That is, PRINT simulates the receipt of host-typed output, and
  379.     all VT100 tricks which the host could use (bold, cursor positioning,
  380.     line and screen clears, line-drawing graphics, etc.) are available.
  381.     The delimited-text may contain CR-LF pairs, in which case the pair
  382.     is reduced to CR and then expanded to CR-LF.  This makes the text
  383.     look right on the screen.  As with all delimited-text, up-arrow
  384.     prefixes may be used to "control-ize" the following characters, so
  385.     "^[" will turn into ESCape.  Also, variables may be invoked.
  386.  
  387.                 PRINT    delimited-text
  388.  
  389.     PRINT can also be used in a tricky way to control the program.  By
  390.     using the "enter-server" and "preload-command" escape sequences
  391.     described in VT100.DOC, you can throw the program temporarily into
  392.     Server mode or execute any VTKermit command you want.  Note that
  393.     the preloaded command is executed only when you leave Terminal mode,
  394.     so the script will have to terminate in order to execute the command.
  395.  
  396.            PRINT /^[[H^[[J The screen is now clear./
  397.  
  398.  
  399. PRINTCR
  400.     PRINTCR is identical to PRINT except that a CR-LF is appended to
  401.     the output.  This is for convenience only.
  402.  
  403.                PRINTCR    delimited-text
  404.  
  405.  
  406. SEND
  407.     The SEND command sends text out the serial port.  If the
  408.     delimited-text spans multiple lines, then the CR-LF pairs which
  409.     separate the lines will be sent as CR only.  This is usually what
  410.     is wanted when sending text to a remote host.  If you want to send
  411.     a true LF, you must code "^J" in the delimited-text.
  412.  
  413.                 SEND    delimited-text
  414.  
  415.     SEND is probably the most necessary script command and may be
  416.     the most heavily used.
  417.  
  418.               SEND /AT D%type %phone ^m/
  419.  
  420.  
  421. SENDBR
  422.     SENDBR sends a break signal out the port.  This is sometimes used
  423.     to get the attention of a remote host or intermediate circuit switch.
  424.  
  425.                     SENDBR
  426.  
  427.  
  428. SENDCR
  429.     SENDCR is identical to SEND except that it appends a CR to the sent
  430.     text.  This is for convenience only.
  431.  
  432.                SENDCR    delimited-text
  433.  
  434.     The CR command is a synonym for SENDCR, also only for convenience.
  435.  
  436.  
  437. SLEEP
  438.     The SLEEP command puts the script processor into a "sleeping" state
  439.     in which the keyboard is ignored and host output is directed to the
  440.     screen but otherwise ignored.  This is most useful when dealing with
  441.     hosts or devices which lose input typed at the wrong time.  The SLEEP
  442.     command sleeps for a period numbered in seconds, while the HSLEEP
  443.     command sleeps for a period numbered in hundredths of a second.
  444.  
  445.                 SLEEP    number
  446.  
  447.     The standard Hayes modem, for example, chokes on the sequence
  448.  
  449.              SEND /AT Q0^mAT DT %phone ^m/
  450.  
  451.     but works with the sequence
  452.  
  453.            SEND /AT Q0^m/ ; SLEEP 1 ; SEND /AT DT %phone ^m/
  454.  
  455.     in which the only difference is the delay between sent lines.
  456.  
  457.  
  458. TERMINAL-MODE
  459.     The TERMINAL-MODE command throws you immediately into Terminal
  460.     mode, terminating any number of CALLs.  This is different from
  461.     hitting end-of-file in a script if the script was CALLed, but is
  462.     identical otherwise.
  463.  
  464.                  TERMINAL-MODE
  465.  
  466.  
  467. TIMER
  468.     The TIMER command sets a timer which will abort a later WAIT command
  469.     if none of the desired sequences of host output is seen within the
  470.     timeout period.  This is very useful for determining if a modem is
  471.     attached to a line, for example, since a null response can be timed
  472.     out and action taken.  The TIMER command sets a timer for some number
  473.     of seconds, while the HTIMER command sets a timer for some number of
  474.     hundredths of seconds.  Note that TIMER is aborted by a SLEEP, so any
  475.     desired SLEEPing should be done prior to hitting the TIMER command.
  476.  
  477.                 TIMER    number
  478.  
  479.     As with SLEEP, HSLEEP and HTIMER, number should be 150 or less.  Also,
  480.     a timer is not cleared at the conclusion of a WAIT unless the WAIT was
  481.     ended by a timeout.  Thus, one TIMER may affect more than one WAIT if
  482.     the first WAIT is terminated by host output.  A TIMER may be cleared
  483.     with a TIMER 0 or SLEEP 0 command, or may be reset for the next WAIT.
  484.  
  485.  
  486. WAIT
  487.     The WAIT command halts script processing until either one of several
  488.     desired strings is received from the host or a certain amount of time
  489.     has elapsed.  WAIT can wait for any one of several strings from the
  490.     remote host, but all "waiting" strings must be listed on the same line
  491.     as the WAIT verb.  There may be as many as 10 waiting items, each up
  492.     to 31 characters long.
  493.  
  494.         WAIT    delimited-text    [delimited-text ...]
  495.  
  496.     WAIT is very useful for taking different courses of action depending
  497.     on events seen while trying to dial up a remote host or log in.  In
  498.     combination with the IF command, this can be used for error-detection,
  499.     error-recovery or simply choosing different courses of action.
  500.     Ordinarily, only text received after the WAIT command had begun would
  501.     be seen by the command.  The LISTEN command, described earlier, may be
  502.     used to pre-buffer the host's text for a later WAIT command.
  503.     Also, the WAIT turns off listening when it terminates.  The LWAIT
  504.     command is a variant of WAIT which leaves listening in effect.
  505.  
  506.           WAIT /CONNECTED/ /NOT RESPONDING/ /UNKNOWN/ /ERROR/
  507.  
  508.  
  509. WRITE
  510.     The WRITE command works just like PRINT and SEND, but instead sends
  511.     its output to a disk file which was opened with the OPEN command.  In
  512.     the context of VTKermit, this is most useful for building a self-
  513.     installing script which will build a smaller script file for actual
  514.     use.
  515.  
  516.                 WRITE    delimited-text
  517.  
  518.     For example, you may want to write a script to log any user into your
  519.     system.  You could write a completely general script which asked the
  520.     user for his user ID every time it was run.  However, it might be more
  521.     convenient for the user if he could specify his user ID only once,
  522.     then have it automatically used unless he "reinstalled" his script.
  523.     A "master" script could prompt the user for a user ID and build a
  524.     specific script to log that user in under that user ID every time.
  525.     (The generated script should do the prompting for password, since the
  526.     password may change often and probably shouldn't be stored on disk.)
  527.     The combination of OPEN, WRITE and CLOSE may be used to have one
  528.     script file write another which will then be used to log the user in
  529.     on a daily basis.  If any details asked by the generating script
  530.     change, the script can be run again and another "worker" script
  531.     generated.
  532.     All feature available to other "delimited-texts" may be used here,
  533.     so control-characters and variables may be freely included.  To
  534.     have the generated script include control-ized characters (e.g. to
  535.     have "^m" appear in the generated script) you should code "^^" to
  536.     have the master script generate a "^".  Similarly, to have the
  537.     generated script invoke its own variables, you should write percent-
  538.     percent-space anywhere you need a percent in the generated script.
  539.     Thus,
  540.  
  541.                WRITE "SEND /%% phone /"
  542.  
  543.     will write "SEND /%phone /" to the file, while
  544.  
  545.                 WRITE "SEND /%phone /"
  546.  
  547.     will try to use a master-script variable named %phone.
  548.  
  549. That is the complete set of script commands as of 2 February 1986.  The
  550. remainder of this file presents some examples of the use of these commands.
  551.  
  552. >> To test a Hayes Smartmodem 1200, or to see if one is there ...
  553.  
  554.     Print "^[[H^[[JTesting your Hayes Smartmodem 1200 ...^m"
  555.     HSleep 50            ! Give DTR a chance to go high
  556.     Send "^m" ; HSleep 50        ! First, wake up Hayes modem
  557.     Listen ; Timer 3        ! See if we got it
  558.     Send "AT Q0^m" ; Wait "OK"    ! Did it go ready?
  559.     HSleep 30            ! Short pauses help
  560.     If 255 GoTo Not_responding    ! Looks dead or missing
  561.  
  562.                     ! The modem is here ...
  563.  
  564. >> To see what type or Hayes modem we have, normal or advanced (has X4 and L1)
  565.  
  566. Learn_type:
  567.     HSleep 30            ! Give it a short rest
  568.     Listen ; Timer 3        ! Make modem identify itself
  569.     Send "ATI^m" ; Wait "123" "136"    "OK"
  570.  
  571.     If 2 GoTo Advanced        ! Use special codes on new model
  572.     GoTo Normal            ! Normal Hayes type
  573.  
  574.  
  575. >> To see if user wants Tone or Pulse dialing (T or P for Hayes modem)
  576.  
  577. GType:    Ask %Type /Type "T" for Tone dialing, "P" for Pulse: /
  578.       If %Type = "t" Let %Type = "T"
  579.       If %Type = "p" Let %Type = "P"
  580.       If %Type = "T" GoTo Do_access
  581.       If %Type = "P" GoTo Do_access
  582.       Print "^g? Must be T or P^m" ; Backto GType
  583.  
  584.  
  585. >> Code to generate a script ...
  586.  
  587.     Print "^[[H^[[JGenerating script ...^m"
  588.     Ask %phone "Phone number? "
  589.  
  590.     Open "worker.scr"    ! Open the file for output
  591.  
  592.     Write ~TIMER 30 ; SEND "ATDT%Phone ^m"
  593. WAIT "CONNECT" "NO CARRIER"
  594. SLEEP 1 ; IF 1 GOTO GOT_IN
  595. PRINT "? Couldn't dial up host^^m" ; TERMINAL-MODE
  596. GOT_IN: PRINT "You are in^^m"
  597. ~
  598.     Close            ! Close the new script file
  599.  
  600.     Print "^mScript file generation complete.^m"
  601.     Ask %Ignore "Press ^[[4;7m[Enter]^[[m to return to the menu: "
  602.     Print "^[[H^[[J"
  603.     Command-Mode
  604.  
  605. [End of SCRIPT.DOC]
  606.